﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IndoReputation.Models.BusinessObject;
using IndoReputation.Models.BusinessObject.Collections;
using IndoReputation.Models.DataAccess;

namespace IndoReputation.Models.BusinessLogic
{
    public class OrientationTypeBOL
    {
        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 4/22/2012  6:03 PM
        /// Todo: Insert an orientationType to db
        /// </summary>
        /// <param name="orientationType">The orientationType.</param>
        /// <returns></returns>
        public static int Insert(OrientationType orientationType)
        {
            try
            {
                orientationType.CreateAt = DateTime.Now;
                orientationType.CreateBy = MySession.UserID;
                orientationType.UpdateAt = null;
                orientationType.UpdateBy = null;
                return OrientationTypeDAL.Insert(orientationType);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  9:45 AM
        /// Todo: Update a User Exists in Database 
        /// </summary>
        /// <param name="orientationType">A orientationType.</param>
        /// <returns></returns>
        public static bool Update(OrientationType orientationType)
        {
            try
            {
                orientationType.UpdateAt = DateTime.Now;
                orientationType.UpdateBy = MySession.UserID;
                return OrientationTypeDAL.Update(orientationType);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:36 AM
        /// Todo: Delete a User Existst in Database
        /// </summary>
        /// <param name="orientationType">A orientationType.</param>
        /// <returns></returns>
        public static bool Delete(int orientationTypeID)
        {
            try
            {
                return OrientationTypeDAL.Delete(orientationTypeID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All OrientationType
        /// </summary>
        /// <returns></returns>
        public static OrientationTypeList GetAllOrientationType()
        {
            try
            {
                return OrientationTypeDAL.GetAllOrientationType() ?? new OrientationTypeList();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a User existst in Database
        /// </summary>
        /// <param name="orientationTypeID">The orientationType ID.</param>
        /// <returns></returns>
        public static OrientationType GetOrientationTypeById(int orientationTypeID)
        {
            try
            {
                return OrientationTypeDAL.GetOrientationTypeById(orientationTypeID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
    }
}